<?php

	namespace application\view;

		require_once ("HTMLheaderView.php");
		require_once ("HTMLfooterView.php");
		require_once ("login/controller/LoginController.php");
		require_once ("application/model/RecipeCollectionModel.php");
		require_once ("application/model/Recipe.php");

		class RecipeCollectionView
		{
			private static $adminSection = "adminSection";
			private static $addrecipe = "addrecipe";
			private static $recipeTypeID = "recipeTypeID";
			private static $recipeName = "recipeName";
			private static $myRecipeName = "myRecipeName";
			private static $instructions = "instructions";
			private static $recipeTag = "recipeTag";
			private static $author = "author";
			private static $addButton = "addButton";
			private static $ViewRecipeList = "viewRecipeList";
			private static $Admin = "adminSection";
			private static $editedRecipeName = "editedRecipeName";
			private static $editedInstructions = "editedInstructions";
			private static $editedRecipeTypeID = "editedRecipeTypeID";
			private static $editedRecipeTag = "editedRecipeTag";
			private static $editedAuthorID = "editedAuthorID";
			private static $searchRecipeTag = "searchRecipeTag";
			private static $searchRecipeType = "searchRecipeType";
			private static $searchRecipeAuthor = "searchRecipeAuthor";
			private static $textSearch = "textSearch";	
			private static $addImage = "addImage";	

			private $title = "add TITLE";
			private $infoMessage = "add infoMessage";
			private $message = "";
			private $recipeCollection = array();
			private $recipeId;
			private $myTextSearch;
			private $textAreaInstructions;

			public function __construct(\application\model\RecipeCollectionModel $recipeCollection)
			{
				$this->recipeCollection = $recipeCollection->getRecipeCollection();

				$this->pageHeaderView = new \application\view\HTMLheaderView();
				$this->pageHeaderView->getPageHeader();

				$this->pageFooterView = new \application\view\HTMLfooterView();
				$this->pageFooterView->getPageFooter();

				$this->logInController = new \login\controller\LoginController();
				$this->logInController->startMyApplication();
			}

			//READ////////////////
			public function userWantsToReadRecipeCollectionList()
			{
				if (isset($_GET[self::$ViewRecipeList]) || !$_GET)
					return true;
				return false;
			}

			public function userWantsToReadRecipe()
			{
				if (isset($_GET["Recipe"]))
					return true;
				return false;
			}

			public function userWantsToReadThisRecipe()
			{
				if (isset($_GET["Recipe"]))
				{
					$recipeID = $_GET["Recipe"];
					return $recipeID;

					// if(!isset($this->recipeCollection[$recipeID]))
					// {
					// throw new \Exception("Kunde inte hitta sidan");
					// }
					// else
					// {
					// //return $recipe = $this->recipeCollection[$recipeID-1];
					// return $recipeID;
					// }
				}
			}
			
			//SEARCH////////
			public function userWantsToSearchRecipes()
			{
				if (isset($_GET["ViewRecipeSearch"]))
					return true;
				return false;
			}
			
			public function userWantsToSearchRecipeType()
			{
				if (isset($_GET[self::$searchRecipeType]))
					return true;
				return false;
			}
			
			public function userWantsToSearchRecipeAuthor()
			{
				if (isset($_GET[self::$searchRecipeAuthor]))
					return true;
				return false;
			}
			
			public function userWantsToSearchThisType()
			{
				if (isset($_GET[self::$searchRecipeType]))
				{
					$recipeTypeID = $_GET[self::$searchRecipeType];
					return $recipeTypeID;
				}
			}
			
			public function userWantsToSearchThisAuthor()
			{
				if (isset($_GET[self::$searchRecipeAuthor]))
				{		
					$recipeAuthorID = $_GET[self::$searchRecipeAuthor];
					return $recipeAuthorID;
				}
			}

			public function userWantsToSearchThisText()
			{
				if (isset($_GET[self::$textSearch]))
				{
					$myTextSearch = $this->getCleanInput(self::$textSearch);
					return $myTextSearch;
				}
			}

			public function userWantsToSearchThisTag()
			{
				if (isset($_GET[self::$searchRecipeTag]))
				{
					$myTagSearch = $_POST[self::$searchRecipeTag];
					return $myTagSearch;
				}
			}

			//ADMIN//////////////
			// return TRUE if user wants to work in Admin Section
			public function userWantsToWorkInAdminSection()
			{
					
				if (isset($_GET[self::$adminSection]))
					return true;
				return false;
			}

			// return TRUE if user wants to add a RECIPE
			public function userWantsToAddRecipe()
			{
				if (isset($_GET[self::$addrecipe]))
					return true;
				return false;
			}
			
			public function userWantsToAddImage()
			{
				if (isset($_GET[self::$addImage]))
					return true;
				return false;
			}
			public function userWantsToUpdateRecipe()
			{
				if (isset($_GET["EditRecipe"]))
					return true;
				return false;
			}

			public function userWantsToSaveUpdatedRecipe()
			{

				if (isset($_GET["SaveUpdatedRecipe"]))
					return true;
				return false;
			}

			public function userWantsToUpdateThisRecipe()
			{
				if (isset($_GET["EditRecipe"]) || isset($_GET["SaveUpdatedRecipe"]))
				{

					if (isset($_GET["EditRecipe"]))
					{
						$recipeID = $_GET["EditRecipe"];
						return $recipeID;

					}
					if (isset($_GET["SaveUpdatedRecipe"]))
					{
						$recipeID = $_GET["SaveUpdatedRecipe"];
					}
					return $recipeID;
				}
			}

			public function userWantsToDeleteRecipe()
			{
				if (isset($_GET["DeleteRecipe"]))
					return true;
				return false;
			}

			public function userWantsToDeleteThisRecipe()
			{
				if (isset($_GET["DeleteRecipe"]) || isset($_GET["ConfirmDeletion"]))
				{

					if (isset($_GET["DeleteRecipe"]))
					{
						$recipeID = $_GET["DeleteRecipe"];
					}

					if (isset($_GET["ConfirmDeletion"]))
					{
						$recipeID = $_GET["ConfirmDeletion"];
					}

					return $recipeID;

					// if(!isset($this->recipeCollection[$recipeID]))
					// {
					// throw new \Exception("Kunde inte hitta sidan");
					// }
					// else
					// {
					// //return $recipe = $this->recipeCollection[$recipeID-1];
					// return $recipeID;
					// }
				}
			}

			public function userIsSureAboutDeletion()
			{
				if (isset($_GET["ConfirmDeletion"]))
				{
					return true;
				}
					return false;
			}
			
			public function userAbortsDeletion()
			{
				if (isset($_GET["AbortDeletion"]))
				{
					return true;
				}
					return false;
			}

			//HTML & FORMS//////////
			public function getEditedRecipe($recipe)
			{
				$RecipeID = $recipe->getRecipeId();
				$myEditedRecipeTags = "";
				$myEditedAuthor= "";
				$myEditedRecipeType= "";
				$oldRecipeName = $recipe->getRecipeName();
				$oldRecipeAuthorID = $recipe->getRecipeAuthorID();
				$oldRecipeTypeID = $recipe->getRecipeTypeID();
				$oldRecipeAuthor = $recipe->getRecipeAuthor();
				$oldRecipeType = $recipe->getRecipeType();
				$oldInstructions = $recipe->getRecipeInstructions();
				$oldRecipeTags = $recipe->getRecipeTags();

				$myEditedRecipeName = $this->getCleanInput(self::$editedRecipeName);
				$myEditedRecipeTypeID = (int)$_POST[self::$editedRecipeTypeID];
				$myEditedAuthorID = (int)$_POST[self::$editedAuthorID];
				$myEditedInstructions = $this->getCleanInput(self::$editedInstructions);
				$myEditedAuthor = $oldRecipeAuthor;
				$myEditedRecipeType = $oldRecipeType;
	
				if ($oldRecipeName === $myEditedRecipeName)
					$myEditedRecipeName = $oldRecipeName;
					
				if ($oldRecipeTypeID == $myEditedRecipeTypeID || $myEditedRecipeTypeID == 0)
					$myEditedRecipeTypeID = $oldRecipeTypeID;

				if ($oldRecipeAuthorID == $myEditedAuthorID || $myEditedAuthorID == 0)
					$myEditedAuthorID = $oldRecipeAuthorID;

				if ($oldInstructions == $myEditedInstructions)
					$myEditedInstructions = $oldInstructions;

				if (isset($_POST[self::$editedRecipeTag]))
				{
					$myTag = $_POST[self::$editedRecipeTag];
					$length = count($myTag);
					$myEditedRecipeTags = "";
					for ($i = 0; $i < $length; $i++)
					{
						//$newRecipeTags[] = $aTag[$i];
						$myEditedRecipeTags .= $myTag[$i] . " ";
					}
				}
				if ($oldRecipeTags == $myEditedRecipeTags)
				{
					$myEditedRecipeTags = $oldRecipeTags;
				}
				try
				{
					return new \application\model\Recipe($RecipeID, 
														$myEditedRecipeName, 
														$myEditedInstructions, 
														$myEditedRecipeType, 
														$myEditedRecipeTypeID,
														$myEditedAuthor, 
														$myEditedAuthorID,
														$myEditedRecipeTags);
				}
				catch(\Exception $e)
				{
					echo "KUNDE INTE SKAPA NYTT RECEPT";
					$this->message = $e->getMessage();
					return false;
				}
			}

			public function getEditFormHTML($recipe, $title, $button, $action)
			{
				$this->title = $title;
				return "<h2>ID: " . $recipe->getRecipeID() . " NAMN: " . $recipe->getRecipeName() . "</h2>
				<form id=\"form\" name=\"form\" method=\"post\" action=\"?" . $action . $recipe->getRecipeID() . "\">
				<fieldset><legend>" . $this->title . "</legend><br><br>
				<p class='edittyp'>Receptnamn: " . $recipe->getRecipeName() . "</p>
				<div id=\"editButton1\" class=\"EditB\"></div>
				
				<div id=\"hidden0\" class=\"hide\">
				<label for=\"name\">Receptnamn</label>
				<input type=\"text\" id=\"name\" name=\" " . self::$editedRecipeName . "\" value=\"" . $recipe->getRecipeName() . "\"/>
				</div>
				
				<p class='edittyp'>Recepttyp: " . $recipe->getRecipeType() . "</p>
				<div id=\"editButton1\" class=\"EditB\"></div>
				
				<div id=\"hidden1\" class=\"hide\">
				<label>Recepttyp</label>
                    <select name=\"" . self::$editedRecipeTypeID . "\">
                    <option value=\"0\></option>
      			    <option value=\"4\">Förrätt</option>
			        <option value=\"5\">Varmrätt</option>
			        <option value=\"6\">Efterrätt</option>
			        <option value=\"7\">Bakverk</option>
			        <option value=\"8\">Annat</option>
			        </select>
			   </div>

			   <p class='edittyp'>Författare: " . $recipe->getRecipeAuthor() . "</p><br> 
			   <div id=\"editButton1\" class=\"EditB\"></div>    
			   
			   <div id=\"hidden2\" class=\"hide\">
			   <label>Författare</label>
                    <select name=\"" . self::$editedAuthorID . "\">
  			        <option value=\"0\></option>
  			        <option value=\"2\">Anna</option>
			        <option value=\"3\">Kristina</option>
			        <option value=\"1\">Jenni</option>
			        </select>
			         </div>

			   <p class='edittyp'>Etiketter: " . $recipe->getRecipeTags() . "</p>
			   <div id=\"editButton1\" class=\"EditB\"></div>
			   
			   <div id=\"hidden3\" class=\"hide\">
			  
			   <label>Etikett</label>
                    <div  class=\"checkbox\"><input type=\"checkbox\" name=\"" . self::$editedRecipeTag . "[]\" value=\"Buffé\" /> Buffé</div>
                    <div  class=\"checkbox\"><input type=\"checkbox\" name=\"" . self::$editedRecipeTag . "[]\" value=\"Jul\" /> Jul</div>
                    <div  class=\"checkbox\"><input type=\"checkbox\" name=\"" . self::$editedRecipeTag . "[]\" value=\"Påsk\" /> Påsk</div>
                    <div  class=\"checkbox\"><input type=\"checkbox\" name=\"" . self::$editedRecipeTag . "[]\" value=\"Sill\" /> Sill</div>
                    <div  class=\"checkbox\"><input type=\"checkbox\" name=\"" . self::$editedRecipeTag . "[]\" value=\"Sommar\" /> Sommar</div>         
               </div>
               
                <p class='edittyp'>Instruktioner:</p><div id=\"editButton1\" class=\"EditB\"></div>
                <div class=\"editBox\"><p>" . $recipe->getRecipeInstructions() . "</p><br> </div>
                
                <div id=\"hidden4\" class=\"hide\">
				<label for=\"textarea\">Instruktioner</label>
				<textarea rows='4' cols='50' id=\"" . self::$editedInstructions . "\" name=\" " . self::$editedInstructions . "\" value=\"" . self::$editedInstructions . "\">" . $recipe->getRecipeInstructions() . "</textarea></div></fieldset>
				
				<button  type=\"submit\" name=\" " . $button . "\">$button</button>
				<fieldset>
				</fieldset></form>";
			}

			// return Recipe
			public function getNewRecipe()
			{
				//Hämtar in posterna
				$newRecipeID = null;
				$emptyString = "";
				$newRecipeName = $this->getCleanInput(self::$myRecipeName);
				$newInstructions = $this->getCleanInput(self::$instructions);
				$newRecipeTypeID = (int)$_POST[self::$recipeTypeID];
				$newAuthorID = (int)$_POST[self::$author];
				
				//Kollar om användare valt en eller flera "taggar"
				if (isset($_POST[self::$recipeTag]))
				{
					$myTag = $_POST[self::$recipeTag];
					$length = count($myTag);
					$newRecipeTags = "";

					for ($i = 0; $i < $length; $i++)
					{
						//$newRecipeTags[] = $aTag[$i];
						$newRecipeTags .= $myTag[$i] . " ";
					}
				}
				else
				{
					$newRecipeTags = "";
				}

				//TODO gör validering här annars inte lönt att skicka vidare
				try
				{
					return new \application\model\Recipe($newRecipeID,
														 $newRecipeName,
														 $newInstructions,
														 $emptyString, 
														 $newRecipeTypeID ,
														 $emptyString,
														 $newAuthorID,
														 $newRecipeTags);
				}
				catch(\Exception $e)
				{
					$this->message = $e->getMessage();
					return false;
				}
			}

			//return Recipe Collection List Page as String
			public function getRecipeCollectionListHTML()
			{
				$nr = 0;

				$returnValue = $this->pageHeaderView->getPageHeader();
				$returnValue .= $this->logInController->startMyApplication();

				$returnValue .= "<div class='recipeListContent'> <ol>";
				foreach ($this->recipeCollection as $recipe)
				{
					$nr++;
					$returnValue .= "<li>" . $this->getRecipeHTML($recipe, $nr) . " </li>";
				}
				$returnValue .= "</ol></div>";
				$returnValue .= $this->pageFooterView->getPageFooter();
				return $returnValue;
			}
			
			public function getRecipeCollectionListRequested($requestedRecipeCollection)
			{
				$nr = 0;

				$returnValue = $this->pageHeaderView->getPageHeader();
				$returnValue .= $this->logInController->startMyApplication();
				//TODO Göra dynamisk rubrik
				$returnValue .="<h1>Sökresultat</h1>";
				$returnValue .= "<div class='recipeListContent'> <ol>";
				foreach ($requestedRecipeCollection as $recipe)
				{
					$nr++;
					$returnValue .= "<li>" . $this->getRecipeHTML($recipe, $nr) . " </li>";
				}
				$returnValue .= "</ol></div>";
				$returnValue .= $this->pageFooterView->getPageFooter();
				return $returnValue;
			}
			
			public function getFullRecipeHTML($recipe)
			{
				$returnValue = $this->pageHeaderView->getPageHeader();
				$returnValue .= $this->logInController->startMyApplication();

				$returnValue .= "
                <div class='recipeBox'>
                    <h2>ID: " . $recipe->getRecipeID() . " " . $recipe->getRecipeName() . "</h2>
                    <br><p class='bold'>Instruktioner:</p>
                    <p>" . $recipe->getRecipeInstructions() . "</p><br> 
                    <p class='typ'>Författare: " . $recipe->getRecipeAuthor() . "</p>                  
                    <p class='typ'>Recepttyp: " . $recipe->getRecipeType() . "</p>
                    <p class='typ'>Etiketter: " . $recipe->getRecipeTags() . "</p>
                    <div class=\"buttonBox\">
                    <a class=\"JBButtonlink\" href=\" ?EditRecipe=" . $recipe->getRecipeID() . "\">REDIGERA</a>
                    <a class=\"JBButtonlink\" href=\" ?DeleteRecipe=" . $recipe->getRecipeID() . "\">TA BORT</a><br>
                    </div> 
                </div> \n";
				$returnValue .= $this->pageFooterView->getPageFooter();
				return $returnValue;
			}

			//ADMINsidan med formulär för nytt recept
			public function getAdminSectionAddRecipe()
			{
				$returnValue = $this->createPage($this->getAddNewRecipeForm("Lägg till Recept"));
				return $returnValue;
			}

			public function getAddNewRecipeForm($title)
			{
				$this->textAreaInstructions = $this->textAreaInstructions;	
				$myRecipeName = $this->getCleanInput(self::$myRecipeName);
				$instructions = $this->getCleanInput(self::$instructions);
				$this->textAreaInstructions = $instructions;
				$this->title = $title;


				return "<form id=\"form\" name=\"form\" method=\"post\" action=\"?" . self::$addrecipe . "\">
				<fieldset><legend>" . $this->title . "<br></legend>
				<label for=\"name\">Receptnamn</label>
				<input type=\"text\" id=\"" . self::$myRecipeName . "\" name=\" " . self::$myRecipeName . "\" value=\"" . $myRecipeName . "\"/>
				
				<label>Recepttyp</label>
                    <select name=\"" . self::$recipeTypeID . "\">
      			    <option value=\"4\">Förrätt</option>
			        <option value=\"5\">Varmrätt</option>
			        <option value=\"6\">Efterrätt</option>
			        <option value=\"7\">Bakverk</option>
			        <option value=\"8\">Annat</option>
			        </select>
			        
			   <label>Författare</label>
                    <select name=\"" . self::$author . "\">
  			        <option value=\"2\">Anna</option>
			        <option value=\"3\">Kristina</option>
			        <option value=\"1\">Jenni</option>
			        </select>
			        
			   <div class=\"whiteBox\">
			   <label>Etikett</label>
                    <div  class=\"checkbox\"><input type=\"checkbox\" name=\"" . self::$recipeTag . "[]\" value=\"Buffé\" /> Buffé</div>
                    <div  class=\"checkbox\"><input type=\"checkbox\" name=\"" . self::$recipeTag . "[]\" value=\"Jul\" /> Jul</div>
                    <div  class=\"checkbox\"><input type=\"checkbox\" name=\"" . self::$recipeTag . "[]\" value=\"Påsk\" /> Påsk</div>
                    <div  class=\"checkbox\"><input type=\"checkbox\" name=\"" . self::$recipeTag . "[]\" value=\"Sill\" /> Sill</div>
                    <div  class=\"checkbox\"><input type=\"checkbox\" name=\"" . self::$recipeTag . "[]\" value=\"Sommar\" /> Sommar</div>
               </div>

				<label for=\"textarea\">Instruktioner</label>
				<textarea rows='4' cols='50' id=\"" . self::$instructions . "\" name=\" " . self::$instructions . "\" value=\"\">" . $this->textAreaInstructions . "</textarea></fieldset>
				
				<fieldset><button  type=\"submit\" name=\" " . self::$addButton . "\">Lägg till recept</button>
				</fieldset></form>
				<br><br>
				
				
				<div class=\"uploadImgBox\">
				<form id=\"form\" name=\"form\" method=\"post\" action=\"?" . self::$addImage . "\" enctype=\"multipart/form-data\">
				<br><br><label for=\"file\">LADDA UPP EN BILD:</label><input type=\"file\" name=\"file\" id=\"file\"><br>
				<input type=\"submit\" name=\" \" value=\"Lägg till bild\">
				</form></div>";
			}

			public function getEditFormPage($recipe)
			{
				$returnValue = $this->createPage($this->getEditFormHTML($recipe, "REDIGERA RECEPT", "SPARA ÄNDRINGAR", "SaveUpdatedRecipe="));
				return $returnValue;
			}

			public function newRecipeAddedSuccess($recipe)
			{
				$this->textAreaInstructions = "";
				$returnValue = $this->createPage($this->getNewRecipeHTML($recipe, "RECEPTET ÄR SKAPAT"));
				return $returnValue;
			}
			
			public function recipeUpdatedSuccess($recipe)
			{
				$returnValue = $this->createPage($this->getNewRecipeHTML($recipe, "ÄNDRINGARNA LYCKADES"));
				return $returnValue;
			}

			public function WorkInAdminSectionFail()
			{
				//$returnValue .= "<div class='errorBox'><p class='errorMessage'>" . $this->message . "</p></div>";
				$returnValue = $this->createPage("<div class='errorBox'><p class='errorMessage'>DU MÅSTE VARA INLOGGAD<br>OM DU VILL ÄNDRA I BRC</p></div>");
				return $returnValue;
			}
			
			public function newRecipeAddedFail()
			{
				//TODO $this->createPage( FIXA DENNA
				$returnValue = $this->pageHeaderView->getPageHeader();
				$returnValue .= $this->logInController->startMyApplication();
				$returnValue .= "<div class='errorBox'><p class='errorMessage'>" . $this->message . "</p></div>";
				$returnValue .= $this->getAddNewRecipeForm("Försök igen");
				$returnValue .= $this->pageFooterView->getPageFooter();
				return $returnValue;
			}

			public function getDeletionConfirmation($recipeId)
			{
				$returnValue = $this->createPage($this->getDoYouReallyHTML($recipeId));
				return $returnValue;
			}

			public function recipeDeletedSuccessPage()
			{
				$returnValue = $this->createPage($this->getDeletedSuccessHTML());
				return $returnValue;
			}

			public function recipeDeletedFail()
			{
				$returnValue = $this->createPage($this->getDeleteFailHTML());
				return $returnValue;
			}
			
			public function createPage($uniqueReturnValue)
			{		
				$returnValue = $this->pageHeaderView->getPageHeader();
				$returnValue .= $this->logInController->startMyApplication();
				$returnValue .= $uniqueReturnValue;
				$returnValue .= $this->pageFooterView->getPageFooter();
				return $returnValue;
			}
			
			//SEARCH
			public function ViewRecipeSearchPage()
			{
				$returnValue = $this->createPage($this->ViewRecipeSearchAlternatives());
				return $returnValue;
			}

			public function ViewRecipeSearchAlternatives()
			{
				return "
				<div class=\"searchBox\">
                <label><h2>SÖK RECEPTTYPER</h2> </label>
                    <a class=\"JBButtonSearchlink\" href=\" ?" . self::$searchRecipeType . "=4". "\">Visa ALLA Förrätter</a>
					<a class=\"JBButtonSearchlink\" href=\" ?" . self::$searchRecipeType . "=5". "\">Visa ALLA Varmrätter</a>
					<a class=\"JBButtonSearchlink\" href=\" ?" . self::$searchRecipeType . "=6". "\">Visa ALLA Efterrätter</a>
					<a class=\"JBButtonSearchlink\" href=\" ?" . self::$searchRecipeType . "=7". "\">Visa ALLA Bakverk</a>
					<a class=\"JBButtonSearchlink\" href=\" ?" . self::$searchRecipeType . "=8". "\">Visa ALLA Annat</a>
				<br><br>
				<div>
				
				<form id=\"formRecipeTagSearch\" name=\"formRecipeTagSearch\" method=\"post\" action=\"?".self::$searchRecipeTag."\">	
			    <label><h2><br>SÖK RECEPTETIKETTER</h2></label>
                    
                    <div  class=\"checkbox2\"><input type=\"radio\" name=\"" . self::$searchRecipeTag . "\" value=\"Buffé\" />Buffé</div>
                    <div  class=\"checkbox2\"><input type=\"radio\" name=\"" . self::$searchRecipeTag . "\" value=\"Jul\" />Jul</div>
                    <div  class=\"checkbox2\"><input type=\"radio\" name=\"" . self::$searchRecipeTag . "\" value=\"Påsk\" />Påsk</div>
                    <div  class=\"checkbox2\"><input type=\"radio\" name=\"" . self::$searchRecipeTag . "\" value=\"Sill\" />Sill</div>
                    <div  class=\"checkbox2\"><input type=\"radio\" name=\"" . self::$searchRecipeTag . "\" value=\"Sommar\" />Sommar</div> 
                    <div  class=\"checkbox2\"><input type=\"radio\"  name=\"" . self::$searchRecipeTag . "\" checked=\"checked\" value=\"Övrigt\"/>Övrigt</div>        
                <button  type=\"submit\" name=\"\">SÖK RECEPTETIKETTER</button></form>
                
                </div>
                <label><h2><br>SÖK FÖRFATTARE</h2></label>
                <a class=\"JBButtonlink\" href=\" ?" . self::$searchRecipeAuthor . "=2". "\">ANNA</a>
				<a class=\"JBButtonlink\" href=\" ?" . self::$searchRecipeAuthor . "=1". "\">JENNI</a>
				<a class=\"JBButtonlink\" href=\" ?" . self::$searchRecipeAuthor . "=3". "\">KRISTINA</a>
                
                <form class=\"whiteBox\" id=\"formTextSearch\" name=\"formTextSearch\" method=\"post\" action=\"?" .self::$textSearch."\">
                <label><h2>SÖK FRITEXT</h2></label> 
				<input type=\"text\" id=\"name\" name=\" " . self::$textSearch . "\" value=\"" . $this->myTextSearch . "\"/>
				
                <button  type=\"submit\" name=\"\">SÖK FRITEXT</button></form></div>";
			}

			private function getDoYouReallyHTML($recipeId)
			{
				$this->recipeId = $recipeId;
				return "
                <div>
                    <h2>VILL DU VERKLIGEN TA BORT DETTA RECEPT!</h2>
                    <p><br><br></p>
                    <a class=\"JBButtonlink\" href=\"?ConfirmDeletion=" . $this->recipeId . "\">JA</a>
                    <br><br><a class=\"JBButtonlink\" href=\"?AbortDeletion=" . $this->recipeId . "\">Nej</a>
                </div> \n";
			}

			private function getDeletedSuccessHTML()
			{
				return "
                <div>
                    <h2>RECEPTET ÄR BORTTAGET!</h2>
                    <p>Vad vill du göra nu?<br><br></p>
                    <a class=\"JBButtonlink\" href=\" ?" . self::$ViewRecipeList . "\">Visa Listan med recept</a>
                    <br><br><a class=\"JBButtonlink\" href=\" ?" . self::$Admin . "\">Lägg till nytt recept</a>
                </div> \n";
			}

			private function getDeleteFailHTML()
			{
				return "
                <div>
                    <h2>Borttagningen Avbröts!</h2>
                    <p>Vad vill du göra nu?<br><br></p>
                    <div class=\"buttonBox\">
                    <a class=\"JBButtonlink\" href=\" ?" . self::$ViewRecipeList . "\">Visa Listan med recept</a>
                    <br><br><a class=\"JBButtonlink\" href=\" ?" . self::$Admin . "\">Lägg till nytt recept</a>
                    </div>
                </div> \n";
			}

			private function getrecipeHTML(\application\model\Recipe $recipe)
			{
				return "
                <div>
                    <h2>ID: " . $recipe->getRecipeID() . " " . $recipe->getRecipeName() . "</h2>
                    <p class='typ'>Recepttyp: " . $recipe->getRecipeType() . "</p>
                    <p class='typ'>Etiketter: " . $recipe->getRecipeTags() . "</p>
                    <p class='typ'>Författare: " . $recipe->getRecipeAuthor() . "</p>
                    <a class=\"JBlink\" href=\" ?Recipe=" . $recipe->getRecipeID() . "\">Läs mer...</a>
                </div> \n";
			}

			private function getNewRecipeHTML(\application\model\Recipe $recipe, $titleText)
			{
				return "
                <div class='recipeBox'>
                <h1>".$titleText."</h1>
                    <h2>ID: " . $recipe->getRecipeID() . " " . $recipe->getRecipeName() . "</h2>
                    <p class='bold'>Instruktioner:</p><p>" . $recipe->getRecipeInstructions() . "</p>
                    <p class='typ'>Recepttyp: " . $recipe->getRecipeType() . "</p>
                    <p class='typ'>Etiketter: " . $recipe->getRecipeTags() . "</p>
                    <p class='typ'>Författare: " . $recipe->getRecipeAuthor() . "</p>
                   
                    <div class=\"buttonBox\"><a class=\"JBButtonlink\" href=\" ?EditRecipe=" . $recipe->getRecipeID() . "\">REDIGERA</a>
                    <a class=\"JBButtonlink\" href=\" ?DeleteRecipe=" . $recipe->getRecipeID() . "\">TA BORT</a></div>
                </div> \n";
			}

			//returns input after sanitation
			//borrowed functions, cleanInput &  sanitizeInput from
			//https://coursepress.lnu.se/kurs/webbutveckling-med-php/exempelsida/en-controller-och-indata/
			private function getCleanInput($inputValue)
			{
				if (isset($_POST[$inputValue]) == false)
				{
					return "";
				}
				return $this->sanitizeInput($_POST[$inputValue]);
			}

			private function sanitizeInput($input)
			{
				$temp = trim($input);
				//TODO medela vid fel??
				return filter_var($temp, FILTER_SANITIZE_STRING, !FILTER_FLAG_STRIP_LOW);
			}


		}
